#!/bin/bash
# author: SheenDong
# date: 2020-03-15 11:22:49

serviceName=$1
profileName=$2


if [[ "$serviceName" = "" ]];then
    echo "wrong number of arguments"
    echo "Usage: bash start.sh [serviceName] [profile]"
    echo "Sample: bash start.sh saas-scrm-manage test"
    exit
fi

if [[ "$profileName" = "" ]];then
    echo "wrong number of arguments"
    echo "Usage: bash start.sh [serviceName] [profile]"
    echo "Sample: bash start.sh saas-scrm-manage test"
    exit
fi

if [ ! -d ".publish/" ]; then
    mkdir .publish
fi

# set properties
JVM_OPTS="-Djava.io.tmpdir=/tmp -XX:+UseParallelGC -Xms512m -Xmx512m"

cp $serviceName/target/$serviceName.jar .publish
nohup java ${JVM_OPTS} -jar ../platform/.publish/$serviceName.jar --spring.profiles.active=$profileName >/dev/null > logs/${serviceName}.log 2>&1 &
echo "start $serviceName by $profileName mode"

tailf logs/$serviceName.log